package org.ben.arithmetic;

import java.util.Arrays;
//将大的数往后放
public class BubbleSort {
	public static void main(String[] args) {
		int[] a= {5,6,9,3,2,7,8,1};
		bubbleSort(a);
		System.out.println(Arrays.toString(a));
	}
	
	public static void bubbleSort(int[] a) {
		for(int i=0;i<a.length-1;i++) {
			for(int j=0;j<a.length-1-i;j++) {
				if(a[j]>a[j+1]) {
					int temp=a[j];
					a[j]=a[j+1];
					a[j+1]=temp;
				}
			}
		}
	}

}
